using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class RecurringPaymentMap : EntityTypeConfiguration<RecurringPayment>
    {
        public RecurringPaymentMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("RecurringPayment");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.CycleLength).HasColumnName("CycleLength");
            this.Property(t => t.CyclePeriodId).HasColumnName("CyclePeriodId");
            this.Property(t => t.TotalCycles).HasColumnName("TotalCycles");
            this.Property(t => t.StartDateUtc).HasColumnName("StartDateUtc");
            this.Property(t => t.IsActive).HasColumnName("IsActive");
            this.Property(t => t.Deleted).HasColumnName("Deleted");
            this.Property(t => t.InitialOrderId).HasColumnName("InitialOrderId");
            this.Property(t => t.CreatedOnUtc).HasColumnName("CreatedOnUtc");

            // Relationships
            this.HasRequired(t => t.Order)
                .WithMany(t => t.RecurringPayments)
                .HasForeignKey(d => d.InitialOrderId);

        }
    }
}
